<template>
    <el-dialog title="检验批" :close-on-click-modal="false" :visible.sync="visible" class="SHZY-dialog SHZY-dialog_center"
        lock-scroll width="70%">
        <el-row :gutter="15" class="">
            <SHZY-table v-loading="listLoading" :data="list">

                <el-table-column label="检验批号" prop="code" width="150" align="left">
                </el-table-column>
                <el-table-column label="检验日期" prop="date" width="150" align="left" :formatter="shzy.tableDateFormat">
                </el-table-column>
                <el-table-column label="报检类型" prop="type" width="100" align="left">
                </el-table-column>
                <el-table-column label="处理状态" prop="status" width="100" align="left">
                    <template slot-scope="scope">
                        <el-tag v-if="scope.row.status == 0" type="info">未检验</el-tag>
                        <el-tag v-if="scope.row.status == 1">检验中</el-tag>
                        <el-tag v-if="scope.row.status == 2" type="success">已检验</el-tag>
                        <el-tag v-if="scope.row.status == 3" type="warning">已过帐</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="检验结果" prop="judgeStatus" width="100" align="left">
                    <template slot-scope="scope">
                        <el-tag v-if="(scope.row.status == 2 || scope.row.status == 3) && scope.row.judgeStatus == 'OK'"
                            type="success">合格</el-tag>
                        <el-tag v-if="(scope.row.status == 2 || scope.row.status == 3) && scope.row.judgeStatus == 'NG'"
                            type="danger">不合格</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="物料" prop="materialCode" min-width="150" :show-overflow-tooltip="true" align="left">
                    <template slot-scope="scope">
                        {{ scope.row.materialCode + " " + scope.row.materialDes }}
                    </template>
                </el-table-column>
                <el-table-column label="供应商" prop="supplier" min-width="150" :show-overflow-tooltip="true" align="left">
                    <template slot-scope="scope">
                        {{ scope.row.supplier + " " + scope.row.supplierDes }}
                    </template>
                </el-table-column>
                <el-table-column label="采购订单号" prop="orderNo" width="150" align="left">
                </el-table-column>
                <el-table-column label="来料数量" prop="incomingQty" width="100" align="left">
                </el-table-column>
                <el-table-column label="批次号" prop="batchNumber" width="150" align="left">
                </el-table-column>
                <el-table-column label="检验员" prop="employeeName" width="100" align="left">
                </el-table-column>
                <el-table-column label="检验类型" prop="inspectType" width="100" align="left">
                    <template slot-scope="scope">
                        {{ getInspectTypeDes(scope.row.inspectType) }}
                    </template>
                </el-table-column>
            </SHZY-table>
            <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize"
                @pagination="initData" />
        </el-row>
        <span slot="footer" class="dialog-footer">
            <el-button @click="visible = false">取 消</el-button>
        </span>
    </el-dialog>
</template>
<script>
import { getExemptionrulerecorddetailList } from '@/api/q1/business/exemptionrulerecord'
export default {
    components: {},
    props: [],
    data() {

        return {
            btnLoading: false,
            loading: false,
            visible: false,
            readOnly: false,
            id: "",
            status: "",
            list: [],
            listLoading: true,
            total: 0,
            listQuery: {
                currentPage: 1,
                pageSize: 20,
                sort: "desc",
                sidx: "",
            },
            batchTypeInfo: []
        }
    },
    computed: {},
    watch: {},
    created() {
        this.getDictionaryData()

    },
    mounted() {
    },
    methods: {
        getDictionaryData() {
            this.$store.dispatch('base/getDictionaryData', { sort: 'BatchType' }).then((res) => {
                this.batchTypeList = res
            })
        },
        getInspectTypeDes(enCode) {
            let batchTypeInfo = this.batchTypeList.find(x => x.enCode == enCode)
            if (batchTypeInfo) {
                return batchTypeInfo.fullName
            } else {
                return ""
            }
        },
        goBack() {
            this.$emit('refresh')
        },
        init(id, status) {
            this.id = id;
            this.status = status
            this.list = []
            this.listQuery = {
                currentPage: 1,
                pageSize: 20,
                sort: "desc",
                sidx: "",
            }

            this.visible = true;
            this.$nextTick(() => {
                this.initData()
            });
        },
        initData() {
            this.listLoading = true;
            let query = {
                ...this.listQuery,
                id: this.id,
                status: this.status
            };
            getExemptionrulerecorddetailList(query).then(res => {
                this.list = res.data.list
                this.total = res.data.pagination.total
                this.listLoading = false
            })
        }
    }
}
</script>
